package main

import (
	"fmt"
	"math/rand"
)

func test1() {
	//打印99乘法表，并要求间隔均匀
	for i := 1; i < 10; i++ {
		for j := 1; j <= i; j++ {
			fmt.Print(i, "*", j, "=", i*j, "\t")
		}
		fmt.Println(" ")
	}

	fmt.Print("--------------------------------------------\n")

	//打印倒三角99乘法表，并要求间隔均匀
	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			if j <= i {
				fmt.Print("\t")
				continue
			}
			fmt.Print(i, "*", j, "=", i*j, "\t")
		}
		fmt.Println(" ")
	}
}

func test2() {
	odd := 0
	even := 1
	for i := 0; i < 20; {
		v := rand.Intn(20)
		//fmt.Println("value is", v, i)
		if v > 0 {
			if v&1 == 1 {
				odd += v
				//fmt.Println("odd is", odd)
			} else {
				even *= v
				//fmt.Println("even is", even)
			}
			i++
		}
	}
	fmt.Println("odd is", odd)
	fmt.Println("even is", even)
}

func test3() {
	a := [50]int{}
	for i := 0; ; i++ {
		if i <= 1 {
			a[i] = 1
		} else {
			a[i] = a[i-1] + a[i-2]
			if a[i] >= 100 {
				break
			}
		}

		fmt.Printf("%d\t", a[i])
		//fmt.Print(a[i],"\t")

	}
}
func main() {
	fmt.Println("---------------------------作业1--------------------------------------")
	test1() //实现99乘法表
	fmt.Println("---------------------------作业2--------------------------------------")
	test2() //随机数累加和累乘
	fmt.Println("---------------------------作业3--------------------------------------")
	test3() //打印100以内斐波那契数列
}
